import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

//公告state对象
const state=null!=window.sessionStorage.getItem('state')?JSON.parse(window.sessionStorage.getItem('state')):{
    userLoginInfo:{
        userId:'',
        username:'',
        nickName:'',
        userType:'',
        email:'',
        phonenumber:'',
        sex:'',
        avatar:'',
        status:'',
        delFlag:'',
        loginIp:'',
        loginDate:'',
        remark:'',
        roleId:'',
    }
}
//响应组件中的事件
const actions={
    asyncUpdateUser(context,userLoginInfo){
        context.commit('updateUserLoginInfo',userLoginInfo)
    }
}
//操作数据
const mutations={
    updateUserLoginInfo(state,userLoginInfo){
        state.userLoginInfo=userLoginInfo;
    }
}
//取值
const getters={
    getUserLoginInfo(state){
        return state.userLoginInfo;
    }
}
//新建并暴露store
export default new Vuex.Store({
    state,
    actions,
    mutations,
    getters
})